package com.ftg.learn.ai.controller;

import com.ftg.learn.ai.servcie.LegalAssistant;
import com.ftg.learn.ai.servcie.ReplyAssistant;
import com.ftg.learn.ai.servcie.StartAssistant;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import reactor.core.publisher.Flux;

@RequestMapping("/chat")
@RestController
@Tag(name = "聊天接口")
@Slf4j
public class ChatController {
    @Autowired
    private LegalAssistant legalAssistant;
    @Autowired
    private StartAssistant startAssistant;
    @Autowired
    private ReplyAssistant replyAssistant;

    @Operation(summary = "聊天助手")
    @GetMapping(produces = "text/event-stream;charset=UTF-8")
    public Flux<String> chat(String message,Long userId) {
        return legalAssistant.chat(message,userId);
    }
    @Operation(summary = "根据评价内容返回评价的类型")
    @PostMapping
    public String sentiment(@RequestBody String message) {
        return startAssistant.analyzeSentimentOf(message).name();
    }

    @Operation(summary = "根据评价内容返回自动回复内容")
    @PostMapping("/reply")
    public String reply(@RequestBody String message) {
        return replyAssistant.reply(message);
    }
}
